package entries;
//import java.util.*;
/**
 * Entry class
 * Keeps track of all information that is saved about identifiers/procedures/functions/arguments
 * Each method displays which kinds can use it
 * @author Keith Davelaar
 * @version 2012.06.04
 *
 */
public abstract class Entry {

	/** Definition of Integer */
	public static final String INTDEF 	= "integer";
	/** Definition of boolean */
	public static final String BOOLDEF 	= "boolean";
	/** Definition of Character */
	public static final String CHARDEF 	= "character";
	
	/** type:boolean */
	public static final char BOOLEAN 	= 'b';
	/** type:character */
	public static final char CHARACTER 	= 'c';
	/** type:Integer */
	public static final char INTEGER 	= 'i';
	/** type:void */
	public static final char VOID		= 'v';
	/** type:NULL */
	public static final char NONE		= 'n';
	
	/** kind:constant */
	public static final int CONSTANT	= 0;
	/** kind:variable */
	public static final int VARIABLE 	= 1;
	/** kind:procedure */
	public static final int PROCEDURE 	= 2;
	/** kind:function */
	public static final int FUNCTION 	= 3;
	/** kind:argument */
	public static final int PARAMETER 	= 4;
	
	/** boolean:true */
	public static final String TRUE 	= "true";
	/** boolean:false */
	public static final String FALSE 	= "false";
	
	/** Type of the Entry (integer, character, boolean, void or none */
	protected char type;
	/** The kind -> VARIABLE or CONSTANT or PROCEDURE or FUNCTION or ARGUMENT */
	protected int kind;

	/**
	 * Calculate the type, based on the Type definition - Used by all kinds
	 * For example for the type definition 'integer' the corresponding type is 'i'
	 * @param type The type definition
	 * @return the type belonging to this type
	 */
	public static char type(String type) {
		char result = Entry.NONE;
		if(type.equals(INTDEF)){
			result = Entry.INTEGER;
		}else if(type.equals(BOOLDEF)){
			result = Entry.BOOLEAN;
		}else if(type.equals(CHARDEF)){
			result = Entry.CHARACTER;
		}
		return result;
	}

	/** 
	 * Get the type of the Entry - Used by all kinds
	 * @return this.type 
	 */
	public char getType(){ return type; }

	/** 
	 * Get the kind of the Entry - Used by all kinds
	 * @return this.kind 
	 */
	public int getKind(){ return kind; }
}
	
	